#pragma once



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <memory>
#include <fstream>
#include <sstream>
#include <string>
#include <unordered_map>
#include <algorithm>
extern "C"
{
#include "sqlite3.h"
};


using namespace std;

class MemoryDB {


public:
	MemoryDB();
    void split(const std::string& s, std::vector<std::string>& v, const std::string& c);
    void create_database();
	void create_table();
	void insert_operation();
	void cmd_sql();
	void select_data();
	void load_config(string str);
	void load_insert_opt(string str);
	void insert_operation_disk(string file);
public:
	string  type(string flag, string & value) {
		if (flag == "1") return "'" + value + "'";
		return value;
	}
public:
	static int callback(void* NotUsed, int argc, char** argv, char** azColName);
	static int cmd_sql_show(void* para, int n_column, char** column_value, char** column_name);
	static int sql_to_file(void* para, int n_column, char** column_value, char** column_name);
	static int table_info(void* para, int n_column, char** column_value, char** column_name);
private:
	sqlite3* m_disk_db;
	sqlite3* m_mem_db;
	static ofstream* ptr_out;
	unordered_map<string, string>  m_table;
	unordered_map<string, string> m_insert_opt;

};
